<?php

declare(strict_types=1);

namespace app\admin\validate;

use think\Validate;

class CustomerInvoicebasicinfo extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'              => ['require', 'integer', 'gt:0'],
        'ids'             => ['require'],
        'customer_id'     => ['require', 'integer', 'gt:0'],
        'invoice_header'  => ['require', 'max:100'],
        'tax_id_num'      => ['require', 'max:100'],
        'register_phone'  => ['max:100'],
        'billing_address' => ['max:255'],
        'opening_bank'    => ['max:100'],
        'opening_account' => ['max:100'],
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require'              => '记录ID不能为空',
        'ids.require'             => '记录ID不能为空',
        'id.integer'              => '记录ID必须是整数',
        'id.gt'                   => '记录ID必须大于0',
        'customer_id.require'     => '客户ID不能为空',
        'customer_id.integer'     => '客户ID必须是整数',
        'customer_id.gt'          => '客户ID必须大于0',
        'invoice_header.require'  => '发票抬头不能为空',
        'invoice_header.max'      => '发票抬头最多不能超过100个字符',
        'tax_id_num.require'      => '纳税识别号不能为空',
        'tax_id_num.max'          => '纳税识别号最多不能超过100个字符',
        'register_phone.max'      => '注册电话最多不能超过100个字符',
        'billing_address.max'     => '开票地址最多不能超过255个字符',
        'opening_bank.max'        => '开户行最多不能超过100个字符',
        'opening_account.max'     => '开户账号最多不能超过100个字符'
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        // 新增
        'create' => [
            'customer_id',
            'invoice_header',
            'tax_id_num',
            'register_phone',
            'billing_address',
            'opening_bank',
            'opening_account'
        ],
        // 更新
        'update' => [
            'id',
            'invoice_header',
            'tax_id_num',
            'register_phone',
            'billing_address',
            'opening_bank',
            'opening_account',
        ],
        // 删除
        'delete' => ['ids'],
        // 查询
        'read' => ['id'],
    ];
}
